package com.crm.manager.controller;

import com.crm.common.core.page.TableDataInfo;
import com.crm.manager.domain.dto.ClueStatisticPageDto;
import com.crm.manager.domain.dto.ContractStatisticPageDto;
import com.crm.manager.domain.vo.StatisticsVo;
import com.crm.manager.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@Slf4j
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;


    // 客户统计
    @GetMapping("/contractStatistics/{beginTime}/{endTime}")
    public StatisticsVo contractStatistics(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate beginTime, @PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endTime){
        log.info("客户统计,开始时间:{},结束时间:{}",beginTime,endTime);
        return reportService.contractStatistics(beginTime,endTime);
    }

    // 线索统计
    @GetMapping("/cluesStatistics/{beginTime}/{endTime}")
    public StatisticsVo cluesStatistics(@PathVariable  @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate beginTime, @PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endTime){
        log.info("线索统计,开始时间:{},结束时间:{}",beginTime,endTime);
        return reportService.cluesStatistics(beginTime,endTime);
    }

    // 客户统计分页查询
    @GetMapping("/contractStatisticsList")
    public TableDataInfo clientStatisticPageQuery(ContractStatisticPageDto dto){
        log.info("客户统计分页查询,接收到的参数是{}",dto);
        return reportService.clientStatisticPageQuery(dto);
    }

    // 线索统计分页查询
    @GetMapping("/cluesStatisticsList")
    public TableDataInfo clueStatisticPageQuery(ClueStatisticPageDto dto){
        log.info("线索统计分页查询,接收到的参数是{}",dto);
        return reportService.clueStatisticPageQuery(dto);
    }
}
